﻿using BCL.WPFComponent.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DevicesWPF.UCDevices.Abaxis
{
    /// <summary>
    /// UCVS2ItemSelect.xaml 的交互逻辑
    /// </summary>
    public partial class UCFuseItemSelect : BaseShowControl
    {
        private Devices.IDevices dev;
        public List<string> Tests { get; private set; }
        public UCFuseItemSelect()
        {
            InitializeComponent();
        }

        public UCFuseItemSelect(Devices.IDevices _cmd)
        {
            InitializeComponent();
            dev = _cmd;
           
        }

        public override void LanguageBinding()
        {

        }

        private void BaseShowControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (dev == null)
                return;
            if (!(dev is Devices.Abaxis.Abaxis_Fuse fuse))
                return;
            panelMain.Children.Clear();
            foreach (var item in fuse.RequestCodes)
                panelMain.Children.Add(new RadioButton { Content = string.Format("{0}({1})",item.Code,item.Name), Tag = item, FontSize = 22, VerticalContentAlignment= VerticalAlignment.Center, Margin=new Thickness(10,0,0,0) });
            (panelMain.Children[0] as RadioButton).IsChecked = true;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void Buttonclose_Click(object sender, RoutedEventArgs e)
        {
            if (panelMain.Children == null || panelMain.Children.Count == 0)
                return;

            foreach (RadioButton item in panelMain.Children)
            {
                if (item.IsChecked == true)
                {
                    Devices.Abaxis.TestItem test = item.Tag as Devices.Abaxis.TestItem;
                    Tests = new List<string> { test.Code };
                    MessageBoxResult = MessageBoxResult.OK;
                    Close();
                }
            }

        }
    }
}
